package com.zz.common.app;



import android.content.ContentResolver;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;

public abstract class BaseFrame {
    private BaseActivity mActivity;
    private View mContentView;
    
    protected void post(Runnable r) {
    	if(null != mContentView) {
    		mContentView.post(r);
    	}
    }

    void setActivity(BaseActivity act) {
        this.mActivity = act;
    }

    void setContentView(View content) {
        this.mContentView = content;
    }

    public View onCreateView(LayoutInflater inflater) {
        return null;
    }

    public final BaseActivity getActivity() {
        return mActivity;
    }
    
    protected void onCreate() {
    }
    
    protected void onStart() {
    	
    }

    protected void onRestart() {
    	
    }
    
    protected void onResume() {

    }

    protected void onPause() {

    }
    
    protected void onStop() {
    }

    protected void onDestroy() {

    }

    protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    }

    public void onConfigurationChanged(Configuration newConfig) {

    }
    
    protected void onSaveInstanceState(Bundle outState) {
    }
    
    protected void onRestoreInstanceState(Bundle savedInstanceState) {
    }

    public Resources getResources() {
        return mActivity.getResources();
    }

    public View findViewById(int id) {
        return mContentView.findViewById(id);
    }

    public void startActivity(Intent intent) {
        mActivity.startActivity(intent);
    }

    public void startActivityForResult(Intent intent, int requestCode) {
        mActivity.startActivityForResult(intent, requestCode);
    }

    public String getString(int resId) {
        return mActivity.getString(resId);
    }

    public void runOnUiThread(Runnable action) {
        mActivity.runOnUiThread(action);
    }

    public Object getSystemService(String name) {
        return mActivity.getSystemService(name);
    }

    public ContentResolver getContentResolver() {
        return mActivity.getContentResolver();
    }

    public void finish() {
        mActivity.finish();
    }
}

